<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var str = "How are you? And you?";
        console.log(str.indexOf('y')); // 8
        console.log(str.lastIndexOf('y')); // 17
        console.log(str.charAt(8)); // y
        console.log(str.charCodeAt(8)); // 121 获取索引为8的位置字符的 Unicode编码
        console.log(str.slice(0, 5)); // how a 用法同数组 不改变原字符串 可用于复制字符串

        console.log(str.substr(1, 4)); // ow a 从下标1开始，截取4个 其他同slice()
        console.log(str.substr(0)); // How are you? And you? 截取所有
        
        console.log(str.concat('I am fine,think you!')); // how are you? and you?I am fine,think you!
        console.log(str.toUpperCase()); // HOW ARE YOU? AND YOU?
        console.log(str.toLowerCase()); // how are you? and you?
    </script>
</body>
</html>